/* 
 * File:   ShowDatabases.cpp
 * Author: vikrantsingh
 * 
 * Created on 1 November, 2013, 7:35 PM
 */

#include "ShowDatabases.h"
#include "../dependency/QueryStructures.h"
#include "../BufferManager/BufferManager.h"
#include <map>

ShowDatabases::ShowDatabases() {
}

ShowDatabases::ShowDatabases(const ShowDatabases& orig) {
}

ShowDatabases::~ShowDatabases() {
}

STATUS_CODE ShowDatabases::run(QueryStructures *queryStruct) {
    DEBUG("in showdb");
    BufferManager *bm = BufferManager::getInstance();

    map<string, int> f = bm->listDB();
    if (f.empty()) {
        cout << "NO_DATABASE_EXISTS" << endl;
    } else {
        cout << "Filename:Filesize" << endl;
        for (map<string, int> ::iterator itr = f.begin(); itr != f.end(); itr++) {
            cout << itr->first << ":" << itr->second << endl;
        }

    }

    return SUCCESS;
}